# -*- coding: utf-8 -*-
# @Author  : longbhu
# @Time    : 2025/2/25 10:30
# @Function:
import rasterio
from rasterio.enums import ColorInterp

# 文件路径
file_path = r'F:\test_files\eco\ecosystem_森林生态系统.tif'
# file_path = r'F:\code\dev\calc-gep-regulate-cqc\devCalc\data\A003_生态系统分类栅格图_商洛-GCS_WGS_1984.tif'

# 打开 TIFF 文件
with rasterio.open(file_path) as src:
    # 输出基本信息
    print(f"文件名: {src.name}")
    print(f"驱动: {src.driver}")
    print(f"高度: {src.height}")
    print(f"宽度: {src.width}")
    print(f"波段数: {src.count}")
    print(f"数据类型: {src.dtypes[0]}")
    print(f"坐标参考系统: {src.crs}")
    print(f"变换矩阵: {src.transform}")

    # 输出每个波段的信息
    for i in range(1, src.count + 1):
        band = src.read(i)
        color_interp = src.colorinterp[i - 1]
        print(f"\n波段 {i}:")
        print(f"  数据类型: {band.dtype}")
        print(f"  颜色解释: {color_interp}")
        print(f"  最小值: {band.min()}")
        print(f"  最大值: {band.max()}")
        print(f"  均值: {band.mean()}")
        print(f"  标准差: {band.std()}")
